package com.diandian.backend.client.controller;

import com.diandian.backend.client.service.ClientSettingService;
import com.diandian.base.boot.starter.response.BaseResult;
import com.diandian.backend.client.param.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * [客户端]客户端配置表
 *
 * @author zyz diandian@qq.com
 * @since 1.0.0 2025-09-11
 */
@RestController
@RequestMapping("/client/setting")
public class ClientSettingController {

    @Autowired
    private ClientSettingService iClientSettingService;

    /**
    * 分页查询
    */
    @PostMapping("/page")
    public BaseResult page(@RequestBody ClientSettingPageParam param) {
        param.check();
        return new BaseResult(0, "success", iClientSettingService.page(param.toDTO()));
    }

    /**
     * 根据belong值获取其对应的clientId下的所有配置参数
     */
    @GetMapping("/getByBelong")
    public BaseResult getByBelong(@RequestParam(value = "belong") String belong, @RequestParam(value = "type", required = false) String type) {
        return new BaseResult(0, "success", iClientSettingService.getByBelong(belong, type));
    }

    /**
     * 查询所有的belong
     */
    @PostMapping("/belong")
    public BaseResult getAllBelong() {
        return new BaseResult(0, "success", iClientSettingService.getAllBelong());
    }

}